package edu.task.snake.model;


public class SnakeElement extends Character {
    private int x = 0;
    private int y = 0;
    private SnakeElement next;
    private SnakeElement previously;

    public SnakeElement(int x, int y) {
        this.x = x;
        this.y = y;
    }

    public SnakeElement(int x, int y, SnakeElement next, SnakeElement previously) {
        this.x = x;
        this.y = y;
        if (next != null) {

        }
        this.next = next;
        this.previously = previously;
    }

    public int getX() {
        return x;
    }

    public void setX(int x) {
        this.x = x;
    }

    public int getY() {
        return y;
    }

    public void setY(int y) {
        this.y = y;
    }

    public boolean isFirst() {
        return previously == null;
    }

    public boolean isLast() {
        return next == null;
    }

    public SnakeElement getNext() {
        return next;
    }


    public SnakeElement getPreviously() {
        return previously;
    }


    public void addNext(SnakeElement snakeElement) { //todo if add in middle
        if (snakeElement != null) {
            this.next = snakeElement;
            snakeElement.previously = this;
        }
    }

    public void addPreviosly(SnakeElement snakeElement) { //todo if add in middle
        if (snakeElement != null) {
            this.previously = snakeElement;
            snakeElement.next = this;
        }
    }

    public void removeNext() {
        this.next = null;
    } //todo if add in middle

    public void removePreviosly() {
        this.next = null;
    } //todo if add in middle
}
